package org.oaix.hapi;

import ca.uhn.hl7v2.HL7Exception;
import ca.uhn.hl7v2.model.Message;
import ca.uhn.hl7v2.protocol.ReceivingApplication;
import ca.uhn.hl7v2.protocol.ReceivingApplicationException;
import com.alibaba.fastjson2.JSON;

import java.io.IOException;
import java.util.Map;

public class MyReceivingApplication implements ReceivingApplication {

    @Override
    public Message processMessage(Message message, Map<String, Object> map) throws ReceivingApplicationException, HL7Exception {
        Message message1 = null;
        try {
            System.out.println(JSON.toJSONString(map));
            message1 = message.generateACK();
        } catch (IOException e) {
            throw new RuntimeException(e);
        }
        return message1;
    }

    @Override
    public boolean canProcess(Message message) {
        return true;
    }
}
